package test.client;

import java.awt.Color;
import java.awt.Font;
import java.util.List;
import javax.swing.JTextArea;

import org.je.ufo.Sleep;
import org.je.util.StringUtil;

/**
 * @author fanyifeng 2013-1-10 下午4:54:02
 */
public class ShowText extends JTextArea
{
	private static final long	serialVersionUID	= 1L;

	public ShowText() {
		this.setLineWrap(true);
		this.setEditable(false);
		this.setFont(new Font("微软雅黑", Font.PLAIN, 14));
		this.setForeground(new Color(0, 50, 255));
	}

	public void updateText() {
		StringBuilder bf = new StringBuilder(0);
		if (!StringUtil.isBlankOrNull(UIShared.message)) {
			bf.append(UIShared.message + "\r\n");
		}

		List<String[]> list = UIShared.chartList;
		for (String[] a : list) {
			bf.append("####   [  " + a[0] + "    " + a[1].substring(11).trim() + "  ]   ####\r\n");
			List<String> l = StringUtil.split(a[2], "\n");
			l = StringUtil.deleteBlankOrNull(l);
			StringUtil.trimAll(l);
			for (String s : l) {
				bf.append("    " + s + "\r\n");
			}
		}

		setText(bf.toString().trim());

		Sleep.millis(30);

		int loc = UIShared.showJs.getVerticalScrollBar().getMaximum();
		UIShared.showJs.getVerticalScrollBar().setValue(loc);

	}
}
